<?php  

/**
* 
*/
class JsonParser
{
  protected $_values;
  public function getValues(){
    return $this->_values;
  }
  
  public function __construct($file)
  {
    $preconf = json_decode(file_get_contents($file));
    //var_dump($preconf);
    $this->_values = array();
    $this->_parseObject($preconf);
    //var_dump($this->_values);
  }
  
  public function _parseObject($object,$prefix=''){
    foreach ($object as $key => $value) {
       $r_prefix = $prefix.trim($key);
       if(!is_a($value,'stdClass')){
         $this->_values[$r_prefix] = $value;
       }else{
         $this->_parseObject($value,$r_prefix.'_');
       }
    }
  }
  
  public function extractValues($prefix=''){
    foreach ($this->_values as $key => $value) {
      Config::set($prefix.$key,$value);
    }
  }
}


?>